package com.web.servlet;

import com.service.GoodsService;
import com.service.impl.GoodsServiceImpl;

import javax.servlet.*;
import javax.servlet.http.*;
import javax.servlet.annotation.*;
import java.io.IOException;

@WebServlet("/delGood")
public class DelGoodServlet extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        request.setCharacterEncoding("utf-8");
        int gid =Integer.parseInt(request.getParameter("gid"));
        GoodsService goodsService = new GoodsServiceImpl();
        if(goodsService.del(gid))
           request.getSession().setAttribute("operateFruit","删除成功");
        else
            request.getSession().setAttribute("operateFruit","删除失败");
        request.getRequestDispatcher("goods").forward(request,response);

    }

    @Override
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        this.doGet(request, response);
    }
}
